1. Field of the Invention
The present invention relates to techniques for improving the performance of computer systems. More specifically, the present invention relates to a method and an apparatus for using a primary strand to control a subordinate strand in a processor.
2. Related Art
Some processors support speculative execution, during which a processor can execute program code without committing the results to the architectural state of the processor (i.e., without making the results available to other strands, threads or processors). For example, some processors support a “scout mode,” wherein program code is executed during a stall condition to prefetch cache lines, but results are not committed to the architectural state of the processor. For a detailed description of operating in scout mode, see U.S. Pat. Pub. No. 2005/0223201, entitled “Generating Prefetches by Speculatively Executing Code Through Hardware Scout Threading,” by inventors Shailender Chaudhry and Marc Tremblay, and filing date 19 Dec. 2003 (hereinafter “Chaudhry”).
As described in Chaudhry, during scout mode, the processor can skip certain types of long-latency instructions, which means that the destination registers for these skipped instructions can contain invalid values. In order to prevent the invalid values from being used as inputs for subsequent instructions, the processor marks the registers as “not there” and does not use them as source registers for subsequent instructions. Similarly, if a branch instruction relies on a register or a condition code that is “not there,” the branch instruction is predicted.
Some of these processors also support branch prediction, wherein a processor predicts the outcome of branch instructions to enable the fetch unit to fetch instructions following the branch instruction without being forced to wait for the branch instruction to execute. When the branch is subsequently executed (and resolved), the processor determines if the branch resolution was mispredicted. If so, the processor flushes any instructions which were incorrectly fetched because of the mispredicted branch and returns to the branch instruction to begin re-executing the program code using the correct branch resolution. Otherwise, if the branch was correctly predicted, the processor simply continues executing the program code.
Unfortunately, because a processor may not be able to resolve a branch instruction during scout mode, the processor may not determine that the branch was mispredicted. Consequently, the processor may continue incorrectly fetching instructions based on the misprediction, thereby causing the processor to perform useless computational work and generate unnecessary prefetches (i.e., prefetches that can evict useful cache lines, e.g., cache pollution).